'''

多任务的实现方式：
1，多进程
2，多线程
3，协程
4，线程池
5，进程池
6，greenlet
7，gevent

'''
import threading
from time import sleep
from threading import Thread
from threading import current_thread

def sing():
    curthrd = current_thread()
    print("当前线程的名称是：%s" % curthrd.name)
    print("当前线程的标识符是：%s" % curthrd.ident)
    for i in range(3):
        print("正在唱歌...%d" % i)
        sleep(1)


def dance():
    curthrd = current_thread()
    print("当前线程的名称是：%s" % curthrd.name)
    print("当前线程的标识符是：%s" % curthrd.ident)
    for i in range(3):
        print("正在跳舞...%d" % i)
        sleep(1)

# 多个任务，顺序执行
# sing()
# dance()

# 多个任务，并发执行
t1 = Thread(target=sing)
t2 = Thread(target=dance)
t1.start()
t2.start()

